<template>
	<view class="container">
		<view class="report-item" @click="onclick(v)" v-for="v in tabbleData" :key="v.id">
			<view class="report-title">
				<text class="reason">{{v.title}}</text>
				<view class="state1" v-if="v.repairState.id==7008">{{v.repairState.repairState}}</view>
				<view class="state3" v-if="v.repairState.id==7007">{{v.repairState.repairState}}</view>
				<view class="state2" v-if="v.repairState.id==7009">{{v.repairState.repairState}}</view>
			</view>
			<view class="report-content">
				<view class="report-option">
					<text class="option-item">报修地址</text>
					<text class="option-detail">{{v.house.room}}</text>
				</view>
				<view class="report-option">
					<text class="option-item">报修项目</text>
					<text
						class="option-detail">{{v.secondItem.repairProject.maintenanceItemType}}-{{v.secondItem.secondItemType}}</text>
				</view>
				<view class="report-option">
					<text class="option-item">预约日期</text>
					<text class="option-detail">{{v.orderDate.split(' ')[0]}}</text>
				</view>
			</view>
		</view>

		<!-- <view class="report-item" @click="onclick">
			<view class="report-title">
				<text class="reason">浴霸不出水了</text>
				<view class="state2">维修中</view>
			</view>
			<view class="report-content">
				<view class="report-option">
					<text class="option-item">报修房屋</text>
					<text class="option-detail">南航碧桂园小区101栋2单元401</text>
				</view>
				<view class="report-option">
					<text class="option-item">报修项目</text>
					<text class="option-detail">水暖-浴霸</text>
				</view>
				<view class="report-option">
					<text class="option-item">预约日期</text>
					<text class="option-detail">2021/09/09</text>
				</view>
			</view>
		</view> -->

		<button type="primary" @click="goto('/pages/maintenancereport/maintenanceitems/maintenanceitems')">+
			申请维修</button>
	</view>
</template>

<script>
	import {
		http
	} from '../../../utils/http.js';
	export default {
		data() {
			return {
				page: 1,
				count: 10,
				tabbleData: []
			}
		},
		methods: {
			//渲染
			getData() {
				http({
					url: '/repair/list',
					params: {
						page: this.page,
						limit: this.count
					}
				}).then((res) => {
					if (res.code == '0') {
						this.tabbleData = res.data
						uni.setStorageSync('houseInfor', JSON.stringify(res.data));
					} else {
						uni.showToast({
							title: '数据加载失败',
							icon: 'error',
							duration: 2000
						});
					}
				})
			},
			goto(url) {
				uni.navigateTo({
					url: url
				})
			},
			onclick(v) {
				v = JSON.stringify(v)
				uni.navigateTo({
					url: '/pages/maintenancereport/repairdetails/repairdetails?data=' + v,
				})
			}
		},
		onLoad() {
			this.getData();
		}
	}
</script>

<style lang="less" scoped>
	.container {
		width: 750rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: flex-start;

		.report-item {
			width: 678rpx;
			height: 322rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: space-around;
			border: 1px solid #dee1e6;
			border-radius: 5px;
			margin-top: 40rpx;

			.report-title {
				width: 618rpx;
				height: 108rpx;
				border-bottom: 1px solid #dee1e6;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.reason {
					color: #333333;
					font-size: 32rpx;
					font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
					font-weight: 400;
				}

				.state1 {
					width: 128rpx;
					height: 44rpx;
					color: #2fd178;
					background: #d4f6e3;
					font-size: 24rpx;
					font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
					font-weight: 400;
					border-radius: 4px;
					text-align: center;
					line-height: 44rpx;
				}

				.state2 {
					width: 128rpx;
					height: 44rpx;
					color: red;
					background: #fddfdf;
					font-size: 24rpx;
					font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
					font-weight: 400;
					border-radius: 4px;
					text-align: center;
					line-height: 44rpx;
				}

				.state3 {
					width: 128rpx;
					height: 44rpx;
					color: #0091ea;
					background: #80d8ff;
					font-size: 24rpx;
					font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
					font-weight: 400;
					border-radius: 4px;
					text-align: center;
					line-height: 44rpx;
				}
			}

			.report-content {
				flex: 1;
				width: 618rpx;
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				justify-content: space-around;

				.report-option {
					width: 618rpx;

					.option-item {
						color: #999999FC;
						font-size: 28rpx;
						font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
					}

					.option-detail {
						color: #333333;
						font-size: 28rpx;
						font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
						margin-left: 28rpx;
					}
				}

			}
		}

		button {
			width: 678rpx;
			height: 80rpx;
			margin-top: 80rpx;
			margin-bottom: 80rpx;
			text-align: center;
			line-height: 80rpx;
			background: #007aff;
		}
	}
</style>
